#include "cliFunctions.hpp"
#include "formatHelpers.hpp"
#include <string>
#include <iostream>
#include <regex>


namespace hms
{


void clearCaseFiles(
	const fs::path& caseDir,
	const std::string& caseName,
	bool dryRun
){
	std::regex pattern { caseName + "((\\.pvd)|([0-9]+\\.vt[irspu]))" };
	for( auto&& filepath : fs::directory_iterator( caseDir ) ){
		fs::path filename { filepath.path().filename() };
		if ( std::regex_match(filename.string(), pattern) ){
			std::cout << "Removing " << filename << "...\n";
			if (!dryRun)
				fs::remove( filepath );
		}
	}
}

void clearCaseFiles( const Settings& s ){
	s.logger().debug("Clearing case files...");
	clearCaseFiles( s.caseDir(), s.caseName(), s.dryRun );
}


} // namespace hms
